import Vue from 'vue'
import Vuex from 'vuex'
import axios from "axios"
import admin from "./admin"
import shop from  "./shop"
import goods from "./goods"
import personner from "./personner"
import askForLeave from "./askForLeave"

Vue.use(Vuex)
const state={
    isLoading:false,
    pageIndex:1,
    pageSum:1
};
const mutations = {
    CHANGE_ISLOADING(state,bol){
        state.isLoading = bol;
    },
    CHANGE_PAGE_INFO(state,{pageSum,pageIndex}){
        // console.log(pageSum)
        state.pageIndex = pageIndex;
        state.pageSum = pageSum;
    },

};
    const  actions = {
       async deleteOneById({commit},query={}){
           const {id="",path=""} = query
            const data =  await axios.delete("/delete",{
                params:{
                    id,
                    path
                }
            });

            return data

        }
}

export default new Vuex.Store({
    state,
    mutations,
    actions,
    modules: {
        admin,
        shop,
        goods,
        personner,
        askForLeave
    }
})
